home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 November / PCWNOV07.iso / Software / Freeware / NSIS 2.29 / nsis-2.29-setup.exe / Include / WinVer.nsh < prev    next >
Encoding:
Text File  |  2006-11-03  |  4.0 KB  |  152 lines

  1. ; ---------------------
  2. ;      WinVer.nsh
  3. ; ---------------------
  4. ;
  5. ; LogicLib extensions for handling Windows versions.
  6. ;
  7. ; IsNT checks if the installer is running on Windows NT family (NT4, 2000, XP, etc.)
  8. ;
  9. ;   ${If} ${IsNT}
  10. ;     DetailPrint "Running on NT. Installing Unicode enabled application."
  11. ;   ${Else}
  12. ;     DetailPrint "Not running on NT. Installing ANSI application."
  13. ;   ${EndIf}
  14. ;
  15. ; AtLeastWin<version> checks if the installer is running on Windows version at least as specified.
  16. ; IsWin<version> checks if the installer is running on Windows version exactly as specified.
  17. ; AtMostWin<version> checks if the installer is running on Windows version at most as specified.
  18. ;
  19. ; <version> can be replaced with the following values:
  20. ;
  21. ;   95
  22. ;   98
  23. ;   ME
  24. ;
  25. ;   NT4
  26. ;   2000
  27. ;   XP
  28. ;   2003
  29. ;   Vista
  30. ;
  31. ; Usage examples:
  32. ;
  33. ;   ${If} ${IsNT}
  34. ;   DetailPrint "Running on NT family."
  35. ;   DetailPrint "Surely not running on 95, 98 or ME."
  36. ;   ${AndIf} ${AtLeastWinNT4}
  37. ;     DetailPrint "Running on NT4 or better. Could even be 2003."
  38. ;   ${EndIf}
  39. ;
  40. ;   ${If} ${AtLeastWinXP}
  41. ;     DetailPrint "Running on XP or better."
  42. ;   ${EndIf}
  43. ;
  44. ;   ${If} ${IsWin2000}
  45. ;     DetailPrint "Running on 2000."
  46. ;   ${EndIf}
  47. ;
  48. ;   ${If} ${AtMostWinXP}
  49. ;     DetailPrint "Running on XP or older. Surely not running on Vista. Maybe 98, or even 95."
  50. ;   ${EndIf}
  51. ;
  52. ; Warning:
  53. ;
  54. ;   Windows 95 and NT both use the same version number. To avoid getting NT4 misidentified
  55. ;   as Windows 95 and vice-versa or 98 as a version higher than NT4, always use IsNT to
  56. ;   check if running on the NT family.
  57. ;
  58. ;     ${If} ${AtLeastWin95}
  59. ;     ${And} ${AtMostWinME}
  60. ;       DetailPrint "Running 95, 98 or ME."
  61. ;       DetailPrint "Actually, maybe it's NT4?"
  62. ;       ${If} ${IsNT}
  63. ;         DetailPrint "Yes, it's NT4! oops..."
  64. ;       ${Else}
  65. ;         DetailPrint "Nope, not NT4. phew..."
  66. ;       ${EndIf}
  67. ;     ${EndIf}
  68.  
  69. !verbose push
  70. !verbose 3
  71.  
  72. !ifndef ___WINVER__NSH___
  73. !define ___WINVER__NSH___
  74.  
  75. !include LogicLib.nsh
  76.  
  77. !define WINVER_95 0x400
  78. !define WINVER_98 0x40A ;4.10
  79. !define WINVER_ME 0x45A ;4.90
  80.  
  81. !define WINVER_NT4 0x400
  82. !define WINVER_2000 0x500
  83. !define WINVER_XP 0x501
  84. !define WINVER_2003 0x502
  85. !define WINVER_VISTA 0x600
  86.  
  87. !macro __GetWinVer
  88.   !insertmacro _LOGICLIB_TEMP
  89.   System::Call kernel32::GetVersion()i.s
  90.   Pop $_LOGICLIB_TEMP
  91. !macroend
  92.  
  93. !macro __ParseWinVer
  94.   !insertmacro __GetWinVer
  95.   Push $0
  96.   IntOp $0 $_LOGICLIB_TEMP & 0xff
  97.   IntOp $0 $0 << 8
  98.   IntOp $_LOGICLIB_TEMP $_LOGICLIB_TEMP & 0xff00
  99.   IntOp $_LOGICLIB_TEMP $_LOGICLIB_TEMP >> 8
  100.   IntOp $_LOGICLIB_TEMP $_LOGICLIB_TEMP | $0
  101.   Pop $0
  102. !macroend
  103.  
  104. !macro _IsNT _a _b _t _f
  105.   !insertmacro __GetWinVer
  106.   IntOp $_LOGICLIB_TEMP $_LOGICLIB_TEMP & 0x80000000
  107.   !insertmacro _== $_LOGICLIB_TEMP 0 `${_t}` `${_f}`
  108. !macroend
  109. !define IsNT `"" IsNT ""`
  110.  
  111. !macro __WinVer_DefineOSTest Test OS
  112.  
  113.   !define ${Test}Win${OS} `"" WinVer${Test} ${WINVER_${OS}}`
  114.  
  115. !macroend
  116.  
  117. !macro __WinVer_DefineOSTests Test
  118.  
  119.   !insertmacro __WinVer_DefineOSTest ${Test} 95
  120.   !insertmacro __WinVer_DefineOSTest ${Test} 98
  121.   !insertmacro __WinVer_DefineOSTest ${Test} ME
  122.   !insertmacro __WinVer_DefineOSTest ${Test} NT4
  123.   !insertmacro __WinVer_DefineOSTest ${Test} 2000
  124.   !insertmacro __WinVer_DefineOSTest ${Test} XP
  125.   !insertmacro __WinVer_DefineOSTest ${Test} 2003
  126.   !insertmacro __WinVer_DefineOSTest ${Test} VISTA
  127.  
  128. !macroend
  129.  
  130. !macro _WinVerAtLeast _a _b _t _f
  131.   !insertmacro __ParseWinVer
  132.   !insertmacro _>= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}`
  133. !macroend
  134.  
  135. !macro _WinVerIs _a _b _t _f
  136.   !insertmacro __ParseWinVer
  137.   !insertmacro _= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}`
  138. !macroend
  139.  
  140. !macro _WinVerAtMost _a _b _t _f
  141.   !insertmacro __ParseWinVer
  142.   !insertmacro _<= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}`
  143. !macroend
  144.  
  145. !insertmacro __WinVer_DefineOSTests AtLeast
  146. !insertmacro __WinVer_DefineOSTests Is
  147. !insertmacro __WinVer_DefineOSTests AtMost
  148.  
  149. !endif # !___WINVER__NSH___
  150.  
  151. !verbose pop
  152.